home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / jed096_1.zip / SLANG / SRC / _SLANG.H next >
C/C++ Source or Header  |  1994-04-27  |  7KB  |  247 lines

  1. /* header file for S-Lang internal structures that users do not (should not)
  2.    need.  Use slang.h for that purpose. */
  3. /* 
  4.  * Copyright (c) 1992, 1994 John E. Davis 
  5.  * All rights reserved.
  6.  *
  7.  * Permission is hereby granted, without written agreement and without
  8.  * license or royalty fees, to use, copy, and distribute this
  9.  * software and its documentation for any purpose, provided that the
  10.  * above copyright notice and the following two paragraphs appear in
  11.  * all copies of this software.
  12.  *
  13.  * IN NO EVENT SHALL JOHN E. DAVIS BE LIABLE TO ANY PARTY FOR DIRECT,
  14.  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  15.  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF JOHN E. DAVIS
  16.  * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17.  *
  18.  * JOHN E. DAVIS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
  19.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  20.  * PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
  21.  * BASIS, AND JOHN E. DAVIS HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  22.  * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  23.  */
  24.  
  25.  
  26. #include <stdlib.h>
  27. #include <string.h>
  28. #include "config.h"
  29. #include "jmalloc.h"
  30.  
  31. #ifdef __GO32__
  32. #  define SLANG_SYSTEM_NAME "_IBMPC"
  33. #else
  34. # if defined (msdos) || defined (__os2__)
  35. #  define SLANG_SYSTEM_NAME "_IBMPC"
  36. # else
  37. #  ifdef VMS
  38. #    define SLANG_SYSTEM_NAME "_VMS"
  39. #  else
  40. #    define SLANG_SYSTEM_NAME "_UNIX"
  41. #  endif
  42. # endif
  43. #endif
  44.  
  45.  
  46.  
  47. #define LANG_MAX_SYMBOLS 500
  48. /* maximum number of global symbols--- slang builtin, functions, global vars */
  49.  
  50. /* Subtypes */
  51. #define ERROR_BLOCK    0x01
  52. #define EXIT_BLOCK    0x02
  53. /* gets executed if block encounters error other than stack related */
  54.  
  55.  
  56. /* directive subtypes */
  57. #define LANG_LOOP_MASK    0x80
  58. #define LANG_LOOP    0x81
  59. #define LANG_WHILE    0x82
  60. #define LANG_FOR    0x83
  61. #define LANG_FOREVER    0x84
  62. #define LANG_CFOR    0x85
  63. #define LANG_DOWHILE    0x86
  64.  
  65. #define LANG_IF_MASK    0x40
  66. #define LANG_IF        0x41
  67. #define LANG_IFNOT    0x42
  68. #define LANG_ELSE    0x43
  69.  
  70.  
  71. /* local, global variable assignments
  72.  * The order here is important.  See interp_variable_eqs to see how this
  73.  * is exploited. */
  74. #define LANG_EQS_MASK    0x20
  75. /* local variables */
  76. /* Keep these in this order!! */
  77. #define LANG_LEQS    0x21
  78. #define LANG_LPEQS    0x22
  79. #define LANG_LMEQS    0x23
  80. #define LANG_LPP    0x24
  81. #define LANG_LMM    0x25
  82. /* globals */
  83. /* Keep this on this order!! */
  84. #define LANG_GEQS    0x26
  85. #define LANG_GPEQS    0x27
  86. #define LANG_GMEQS    0x28
  87. #define LANG_GPP    0x29
  88. #define LANG_GMM    0x2A
  89. /* intrinsic variables */
  90. #define LANG_IEQS    0x2B
  91. #define LANG_IPEQS    0x2C
  92. #define LANG_IMEQS    0x2D
  93. #define LANG_IPP    0x2E
  94. #define LANG_IMM    0x2F
  95.  
  96.  
  97. #define LANG_ELSE_MASK    0x10
  98. #define LANG_ANDELSE    0x11
  99. #define LANG_ORELSE    0x12
  100. #define LANG_SWITCH    0x13
  101.  
  102. /* binary stypes and cmp stypes */
  103. #define LANG_EQ        1
  104. #define LANG_NE        2
  105. #define LANG_GT        3
  106. #define LANG_GE        4
  107. #define LANG_LT        5
  108. #define LANG_LE        6
  109. #define LANG_OR        7
  110. #define LANG_PLUS    8
  111. #define LANG_MINUS    9
  112. #define LANG_TIMES    10
  113. #define LANG_DIVIDE    11
  114. #define LANG_AND    12
  115. #define LANG_BAND    13
  116. #define LANG_BOR    14
  117. #define LANG_BXOR    15
  118. #define LANG_SHL    16
  119. #define LANG_SHR    17
  120. #define LANG_MOD    18
  121.  
  122.  
  123. /* UNARY subtypes */
  124. #define LANG_NOT    1
  125. #define LANG_CHS    2
  126. #define LANG_BNOT    3
  127. #define LANG_ABS    4
  128. #define LANG_SIGN    5
  129. #define LANG_SQR    6
  130. #define LANG_MUL2    7
  131.  
  132.  
  133. typedef struct SLBlock_Type
  134.   {
  135.      unsigned short type;
  136.      union 
  137.        {
  138.       struct SLBlock_Type *blk;
  139.       int i_blk;
  140.       SLang_Name_Type *n_blk;
  141.       char *s_blk;
  142.       FLOAT *f_blk;               /*literal float is a pointer */
  143.       long l_blk;
  144.        }
  145.      b;
  146.   }
  147. SLBlock_Type;
  148.  
  149.  
  150. typedef struct SLang_Object_Type
  151. {
  152.    unsigned short type;
  153.    union
  154.      {
  155.     long l_val;
  156.     char *s_val;
  157.     int i_val;
  158.     SLang_Name_Type *n_val;
  159. #ifdef FLOAT_TYPE
  160.     FLOAT f_val;
  161. #endif
  162.      } v;
  163. }  SLang_Object_Type;
  164.  
  165.  
  166. extern void SLcompile(char *);
  167. extern void (*SLcompile_ptr)(char *);
  168.  
  169. typedef struct Lang_Name2_Type
  170. {
  171.    char *name;  int type;
  172. } Lang_Name2_Type;
  173.  
  174. extern void SLstupid_hash(void);
  175.  
  176. typedef struct SLName_Table
  177. {
  178.    struct SLName_Table *next;           /* next table */
  179.    SLang_Name_Type *table;           /* pointer to table */
  180.    int n;                   /* entries in this table */
  181.    char name[32];               /* name of table */
  182.    int ofs[256];               /* offsets into table */
  183. } SLName_Table;
  184.  
  185. extern SLName_Table *SLName_Table_Root;
  186. extern SLang_Name_Type SLang_Name_Table[LANG_MAX_SYMBOLS];
  187.  
  188. extern int SL_eqs_name(char *, Lang_Name2_Type *);
  189. extern Lang_Name2_Type Lang_Binaries[];
  190. extern SLang_Object_Type *SLStack_Pointer;
  191. extern int extract_token(char **, char *);
  192. extern char *SLbyte_compile_name(char *);
  193. extern int SLang_pop(SLang_Object_Type *);
  194. extern char *SLsprintf(void);
  195. extern char *SLexpand_escaped_char(char *, char *);
  196. extern void SLexpand_escaped_string (char *, char *, char *);
  197.  
  198. extern SLang_Object_Type *SLreverse_stack(int *);
  199. extern SLang_Name_Type *SLang_locate_name(char *);
  200.  
  201.  
  202. /* array types */
  203. typedef struct SLArray_Type
  204. {
  205.    int dim;                   /* # of dims (max 3) */
  206.    int x,y,z;                   /* actual dims */
  207.    long ptr;                   /* address of buffer */
  208.    unsigned char type;               /* int, float, etc... */
  209.    unsigned char flags;               /* This is 0 if it is a S-Lang array,
  210.                     * LANG_IVARIABLE if it is read/write
  211.                     * C array, LANG_RVARIABLE if it is 
  212.                     * read only C array.
  213.                     */
  214. } SLArray_Type;
  215.  
  216. /* maximum size of run time stack */
  217. #ifdef msdos
  218. #define LANG_MAX_STACK_LEN 500
  219. #else
  220. #define LANG_MAX_STACK_LEN 1000
  221. #endif
  222.  
  223. extern SLang_Object_Type SLRun_Stack[LANG_MAX_STACK_LEN];
  224. extern SLang_Object_Type *SLStack_Pointer;
  225.  
  226. extern int SLang_Trace;
  227. extern int SLstack_depth(void);
  228.  
  229. extern void SLang_trace_fun(char *);
  230. extern void SLexecute_function(SLang_Name_Type *);
  231. extern char *SLmake_string (char *);
  232.  
  233. /* useful macro to tell if string should be freed after its use. */
  234. #define IS_DATA_STRING(obj)\
  235.    ((((obj).type >> 8) == STRING_TYPE) && (((obj).type & 0xFF) == LANG_DATA))
  236.  
  237. extern int slang_eqs_name(char *, Lang_Name2_Type *);
  238. extern void SLang_push(SLang_Object_Type *);
  239. extern void SLang_push_float(FLOAT);
  240. extern void SLadd_variable(char *);
  241. extern int SLatoi(unsigned char *);
  242. extern void SLadd_name(char *, long, unsigned short);
  243. extern void SLang_clear_error(void);
  244. extern int SLPreprocess_Only;                /* preprocess instead of 
  245.                          * bytecompiling
  246.                          */
  247.